#ifndef CNC_COMPILER_G_CODE_COMPILER_H
#define CNC_COMPILER_G_CODE_COMPILER_H

#include "gc_.h"
// provided interfaces
//	#include "cmdstream.h"
// required interfaces
//	#include "progmgr.h"
// basic component model
#include <bcm/bcm.h>

namespace cnc {

	namespace compiler {

		class GCodeCompiler : public bcm::Identifier<bcm::Component>,
			public GCodeCompilerImpl
		{
		protected:
			GCodeCompiler() : bcm::Identifier<bcm::Component>("gcode", "G Code Compiler")
			{
			}
		protected: // bcm::Component
			virtual bcm::IdentifierData *getProvidedInterfaceTable()
			{
				static bcm::IdentifierData idData[] = {
					{ "cmdstream", "Command Stream" },
					{ 0, 0 }
				};
				return idData;
			}
			virtual bcm::IdentifierData *getRequiredInterfaceTable()
			{
				static bcm::IdentifierData idData[] = {
					{ "progmgr", "Program Manager" },
					{ 0, 0 }
				};
				return idData;
			}
			virtual bcm::Interface *getInterface(const char *id)
			{
				if (std::string("cmdstream") == id)
					return getCommandStream();
				return 0;
			}
			virtual bool setInterface(bcm::Interface *iface)
			{
				if (iface == 0)
					return false;
				if (std::string("progmgr") == iface->getID()) {
					ProgramManager *pmgr = dynamic_cast<ProgramManager *>(iface);
					if (pmgr == 0)
						return false;
					setProgramManager(pmgr);
				} else
					return false;
				return true;
			}
		public:
			static GCodeCompiler &instance()
			{
				static GCodeCompiler object;
				return object;
			}
		};

	} // namespace compiler

} // namespace cnc

#endif
